package com.mobiftpcms.dao.hibernate;

import java.util.List;

import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.mobiftpcms.dao.LogDao;
import com.mobiftpcms.model.Log;

public class LogDaoHibernate implements LogDao {
	
	private org.apache.commons.logging.Log log = LogFactory.getLog(LogDaoHibernate.class);
    private HibernateTemplate hibernateTemplate;
    
    /**
     * Initialize LogDaoHibernate with Hibernate SessionFactory.
     * @param sessionFactory
     */
    @Autowired
    public LogDaoHibernate(final SessionFactory sessionFactory) {
        this.hibernateTemplate = new HibernateTemplate(sessionFactory);
    }
    
    @SuppressWarnings("unchecked")
	public List<Log> getLogs() {
		log.debug("Retrieving all logs");
		return hibernateTemplate.find("from Log order by time desc");
	}

}
